﻿@{
    ViewBag.Title = "";
    var id = Model != null ? Model.ID : 0;
}
@using ZBJF.Warranty.BLL
@using ZBJF.Warranty.WebProvider
@model ZBJF.Warranty.Model.ProductBrands
<ul id="myTab" class="nav nav-tabs">
    <li><a href="/ProductBrands/">品牌列表</a></li>
    <li class="active"><a href="#ProductBrandsEdit" data-toggle="tab">@(id > 0 ? "编辑品牌" : "添加品牌")</a></li>
</ul>
<div id="myTabContent" class="tab-content">
    <div class="tab-pane  fade in active" id="ProductBrandsEdit">
        @using (Html.BeginForm("SaveProductBrand", "ProductBrandS", FormMethod.Post, new { id = "inputForm", name = "inputForm", @class = "form-horizontal", enctype = "multipart/form-data" }))
        {
            @Html.AntiForgeryToken()
            @Html.HiddenFor(c => c.ID)
            @Html.HiddenFor(c => c.ImgUrl)
            <div class="control-group">
                <label class="control-label">品牌名称：</label>
                <div class="controls">
                    @Html.TextBoxFor(m => m.BrandName, new { validate = "{required:true,messages:{required:'请输入品牌名称'}}", onkeyup = "BrandChange()" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">设备类型：</label>
                <div class="controls">
                    @Html.DropDownListFor(m => m.ProductTypeId, ConvertToSelector.Instance.ProductTypeConvertToSelectList(), new { validate = "{required:true,messages:{required:'请选择类型'}}" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">排序：</label>
                <div class="controls">
                    @Html.TextBoxFor(m => m.Sort)
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">图片：</label>
                <div class="controls">
                    <input type="file" name="ImgUrl" />
                    <img src="@(Model!=null?Model.ImgUrl:"")" class="img-thumbnail preview" />
                </div>
            </div>

            <div class="control-group">
                <label class="control-label">备注：</label>
                <div class="controls">
                    @Html.TextAreaFor(m => m.Remark, new { style = "width:500px", maxlength = 1000 })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"></label>
                <div class="controls">
                    <label>
                        @Html.CheckBox("IsAvailable", Model == null ? true : Model.IsAvailable)
                        是否可用
                    </label>
                </div>
            </div>
            <div class="form-actions">
                <input id="btnSubmit" class="btn btn-primary Edit-R" type="button" value="保存" onclick="loading(this)">
                <input id="btnCancel" class="btn" type="button" value="重置" onclick="reset()">
            </div>
        }
    </div>
</div>

@section scripts
{
    @Scripts.Render("~/Bundles/ImagePreview")
    <script type="text/javascript">
        $(function () {
            $("img.preview").preview();
        });
        function reset() {
            document.getElementById("inputForm").reset();
        }
        function loading(_this) {
            if ($("#inputForm").valid()) {
                _this.disabled = 'disabled';
                document.getElementById("inputForm").submit();
            }
        }
    </script>
}
